<template>
    <div class="example1-wrapper">
        <div class="inner" style="height:480px">
            <bk-virtual-scroll ref="numberVirtualScroll"
                class="number-virtual-scroll"
                :item-height="250"
                :list="data"
                @change="listChange">
                <template slot-scope="item">
                    <bk-card :key="item" title="商户信息" style="height:240px">
                        <div style="float:right;margin-right:200px">
                            <p style="font-size:15px">店铺评分(满分为5分):</p>
                            <p>速度:{{ item.data.rates }}</p>
                            <bk-rate :rate.sync="item.data.rates" :edit="false" :width="20" :height="20"></bk-rate>
                            <p>价格:{{ item.data.ratep }}</p>
                            <bk-rate :rate.sync="item.data.ratep" :edit="false" :width="20" :height="20"></bk-rate>
                            <p>质量:{{ item.data.rateq }}</p>
                            <bk-rate :rate.sync="item.data.rateq" :edit="false" :width="20" :height="20"></bk-rate>
                        </div>
                        <div style="font-size:18px;color:#313238">
                            <p>用户名:{{ item.data.username }}</p>
                            <p>真实姓名:{{ item.data.realname }}</p>
                            <p>地址:{{ item.data.address }}</p>
                            <p>电话:{{ item.data.tel }}</p>
                        </div>
                        <p style="font-size:18px;color:#699DF4">近15日订单数:{{ item.data.ordernum }}</p>
                    </bk-card>
                </template>
            </bk-virtual-scroll>
        </div>
    </div>
</template>

<script>
    export default {
        inject: ['reload'],
        components: {
        },
        data () {
            const user = sessionStorage.getItem('user')
            // console.log(user)
            if (user) {
                const username = JSON.parse(user)
                this.username = username
            }
            this.getmerchant()
            return {
                username: '',
                mername: '',
                data: [
                ],
                Paging: {
                    current: 1,
                    limit: 3,
                    count: 300
                }
            }
        },
        created () {
        },
        methods: {
            /**
             * 获取页面数据
             *
             * @return {Promise} promise 对象
             */
            getmerchant () {
                this.axios({
                    url: '/getmerchant/',
                    method: 'post',
                    responseType: 'json'
                }).then(res => {
                    if (res.data.result === true) {
                        for (const i in res.data.result_data) {
                            const tmp = {
                                username: '',
                                realname: '',
                                address: '',
                                tel: '',
                                rates: '',
                                ratep: '',
                                rateq: '',
                                ordernum: ''
                            }
                            tmp.realname = res.data.result_data[i].realname
                            tmp.address = res.data.result_data[i].address
                            tmp.username = res.data.result_data[i].username
                            tmp.tel = res.data.result_data[i].tel
                            tmp.rates = res.data.result_data[i].rates
                            tmp.ratep = res.data.result_data[i].ratep
                            tmp.rateq = res.data.result_data[i].rateq
                            tmp.ordernum = res.data.result_data[i].ordernum
                            this.$set(this.data, i, tmp)
                        }
                    }
                })
            }
        }
    }
</script>

<style scoped>
</style>
